<template>
  <div>
    <form>
      欢迎你{{ store.state.name}}
      <p>用户名</p> <input type="text" v-model="name"></input>
      <p>密码</p> <input type="text" v-model="password"></input>
      <button @click="setNameByAction">登录</button>
      </input>
    </form>
  </div>
</template>


<script setup>
import { ref, computed } from 'vue'
import { useStore } from 'vuex'

const store = useStore()

const name = ref('')
const password = ref('')

const setNameByAction = (event) => {
  event.preventDefault()
  store.dispatch('setNameByAction', { name: name.value, password: password.value })
}

</script>

<style scoped>
header {
  line-height: 1.5;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

@media (min-width: 1024px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    place-items: flex-start;
    flex-wrap: wrap;
  }
}
</style>
